package com.egrid.point.bury.controller;

import com.egrid.point.bury.code.Response;
import com.egrid.point.bury.code.SimpleResponse;
import com.egrid.point.bury.entity.ConfigProperties;
import com.egrid.point.bury.service.ConfigPropertiesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ConfigPropertiesController.java
 * Created at 2019-12-27
 * Created by Royal Warmer
 * Copyright (C) 2018 SAIC VOLKSWAGEN, All rights reserved.
 */
@RestController
@Api("配置埋点")
@RequestMapping("/config/properties")
@CrossOrigin
public class ConfigPropertiesController {

    @Autowired
    private ConfigPropertiesService service;

    @PostMapping
    @ApiOperation("提交配置")
    public Response save(@RequestBody ConfigProperties configProperties) {
        String save = this.service.save(configProperties);
        return SimpleResponse.success(save);
    }

    @GetMapping
    @ApiOperation("加载配置")
    public Response load() {
        ConfigProperties properties = this.service.loadProperties();
        return SimpleResponse.success("查询成功",properties);
    }

}
